package com.quanyan.club.service;

import com.quanyan.activity.entity.ActivityInfo;
import com.quanyan.activity.response.RespActivityPoster;
import com.quanyan.api.APIResponse;
import com.quanyan.club.entity.db.TbClub;
import com.quanyan.club.entity.db.TbClubActivity;
import com.quanyan.club.entity.db.TbOrder;
import com.quanyan.club.entity.db.TbOrderRefund;
import com.quanyan.club.entity.vo.req.*;
import com.quanyan.club.entity.vo.resp.ResActivityOrder;
import com.quanyan.club.entity.vo.resp.ResActivityOrderDetail;
import com.quanyan.club.entity.vo.resp.ResClubActivityMemberManage;
import com.quanyan.club.entity.vo.resp.ResClubPayAndAccountInfo;
import com.quanyan.club.entity.vo.resp.ResPrePaymentOrderInfo;
import com.quanyan.club.entity.vo.resp.RespClubActivity;
import com.quanyan.club.entity.vo.resp.RespClubActivityMember;
import com.quanyan.club.entity.RespClubMember;
import com.quanyan.club.entity.vo.resp.RespCreateClubActivity;
import com.quanyan.club.entity.vo.resp.RespMyDetailSearchActivity;
import com.quanyan.club.entity.vo.resp.RespSearchActivity;
import com.quanyan.club.entity.vo.resp.RespShareActivity;
import com.quanyan.comment.response.RespComment;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.orderpay.response.RespPreOrder;
import com.quanyan.orderpay.response.mq.OrderNotifyMsg;
import com.quanyan.orderpay.response.mq.RefundNotifyMsg;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

/**
 * ClubActivityService
 *
 * @author Li Shuai
 * @date 16/5/27
 */
public interface ClubActivityService {

    /**
     * 活动详情
     */
    APIResponse<RespClubActivity> queryClubActivityById(Integer activityId, Integer uid);

    /**
     * 活动详情(简要)
     */
    APIResponse<RespClubActivity> queryClubActivityById(Integer activityId);

    /**
     * 活动分享
     */
    APIResponse<RespShareActivity> shareClubActivityById(Integer activityId, HttpServletRequest request);

    /**
     * 搜索活动列表
     */
    APIResponse<PageObj<List<RespSearchActivity>>> queryActivityListByCondition(
            ReqClubActivitySearch reqActivitySearch);

    /**
     * 搜索活动列表，与我相关的活动列表，包括创建的，管理的，加入的。
     */
    APIResponse<RespMyDetailSearchActivity> queryMyDetailActivityListByCondition(
            ReqClubActivitySearch reqActivitySearch, Integer uid);

    /**
     * 收藏 取消活动
     *
     * @param type 收藏 取消
     */
    APIResponse<?> collect(Integer uid, Integer activityId, Integer type);

    /**
     * 收藏的活动列表
     */
    APIResponse<PageObj<List<RespClubActivity>>> queryActivityListCollect(Integer uid,
                                                                          Integer pageIndex,
                                                                          Integer pageSize);
    /**
     * 活动预支付下单
     */
    APIResponse<ResPrePaymentOrderInfo> activityPrePaymentOrder(ReqSignUpInfo reqSignUpInfo,
                                                                Integer currentUserId, HttpServletRequest request);

    /**
     * 活动报名
     *
     * @param currentUserId 当前登陆用户Id
     */
    APIResponse<RespPreOrder> activitySignUp(ReqSignUpDetail reqSignUpInfo,
                                             Integer currentUserId, String requestIp,
                                             String appVersion,
                                             HttpServletRequest request);

    /**
     * 继续支付(下单后没有立马支付的情况)
     */
    APIResponse<RespPreOrder> continuePayActivityOrder(
            ReqClubContinuePayOrder reqClubContinuePayOrder, String appVersion,
            HttpServletRequest request);

    /**
     * 锁定活动人数库存
     */
    APIResponse lockActivityPersonNum(ReqSignUpInfo reqSignUpInfo, Integer limitNum);

    /**
     * 我的活动(订单列表)
     */
    APIResponse<PageObj<List<ResActivityOrder>>> activityOrderList(
            Integer uid, Integer pageNum, Integer pageSize);

    /**
     * 俱乐部活动订单详情
     */
    APIResponse<ResActivityOrderDetail> activityOrderDetail(Integer activityId,
                                                            Integer currentUserId,
                                                            String businessOrderNo);

    /**
     * 活动评价
     */
    APIResponse activityAppraise(Integer userId, Integer activityId,
                                 Integer score, String content, String businessOrderNo,
                                 List<String> lstPic);

    /**
     * 俱乐部现场管理列表
     */
    APIResponse<Map<String, Object>> memberManageList(
            Integer userId, Integer activityId, Integer clubId);

    /**
     * 俱乐部现场管理提交
     */
    APIResponse memberManagerSubmit(Integer userId,
                                    List<ResClubActivityMemberManage> resClubActivityMemberManages);

    /**
     * 俱乐部活动结算明细列表
     */
    APIResponse<Map<String, Object>> settlementDetailList(
            Integer uid, ReqClubActivityInfo reqClubActivityInfo);

    /**
     * 活动结算
     */
    APIResponse activitySettlement(Integer activityId, Integer clubId, Integer userId, boolean isAuto);

    /**
     * 活动自动结算
     */
    void activitySettlementAuto(Integer activityId, Integer clubId, Integer userId);

    /**
     * 暂停活动
     * @param reqSuspendInfo
     * @return
     */
    APIResponse suspendActivity(ReqSuspendInfo reqSuspendInfo);

    /**
     * 恢复暂停活动
     * @param reqSuspendInfo
     * @return
     */
    APIResponse reSuspendActivity(ReqSuspendInfo reqSuspendInfo);

    /**
     * 取消俱乐部活动
     * @param activityId
     * @param uid
     * @return
     */
    APIResponse cancelActivity(Integer activityId, Integer uid, boolean isAdmin, int larkAppId);

    /**
     * 补报名成员账户列表
     *
     * @param userId 当前登陆用户Id
     */
    APIResponse<List<RespClubMember>> clubMemberAccountList(
            Integer userId, ReqClubMemberAccount reqClubMemberAccount);

    /**
     * 活动补报名
     */
    APIResponse memberManageMendSignUp(Integer userId,
                                       ReqClubActivityMendSignUp reqClubActivityMendSignUp);

    /**
     * 用户自己取消订单，申请取消，通知支付系统退款
     */
    APIResponse cancelOrderNotify(Integer uid, String orderNo, Integer cancelType, String reason);

    /**
     * 支付系统退款后，通过MQ发送退款处理结果通知，收到通知后处理订单状态
     */
    boolean cancelOrderNotifyCallback(String businessOrderNo);

    /**
     * 支付系统退款后,通过MQ发送退款处理结果通知，收到通知后处理订单状态(百灵鸟官方后台管理员退款)
     */
    boolean cancelOrderNotifyCallbackAdmin(String businessOrderNo);

    /**
     * 支付系统退款后，通过MQ发送退款处理结果通知，收到通知后处理订单状态
     */
    boolean cancelActivityOrderAdminCallback(RefundNotifyMsg refundNotifyMsg);

    /**
     * 处理活动报名支付回调
     */
    APIResponse handleActivityPayResponse(String msgId, OrderNotifyMsg orderNotifyMsg);

    /**
     * 处理订单关闭回调
     */
    APIResponse handleActivityOrderCloseCallBack(OrderNotifyMsg orderNotifyMsg);

    /**
     * 处理活动结算AA退款回调
     */
    APIResponse handleActivitySettlementAARefundCallback(RefundNotifyMsg refundNotifyMsg,
                                                         TbOrderRefund tbOrderRefund);

    /**
     * 记录活动结算流水
     */
    APIResponse recordActivitySettlementStream(List<TbOrder> orderList,
                                               Integer activityId, Integer clubId);

    /**
     * 活动海报列表
     */
    PageObj<List<RespActivityPoster>> selectActivityPosterList(
            Integer pageNum, Integer pageSize, Integer categoryId, Integer clubId);

    /**
     * 批量增加活动海报列表
     */
    APIResponse batchAddActivityPoster(
            List<String> urls, int uid, int categoryId, int clubId);

    /**
     * 批量删除活动海报列表
     */
    APIResponse batchDeleteActivityPoster(
            List<Integer> posterIds, int clubId, int uid);

    /**
     * 取消未支付订单
     */
    APIResponse cancelNotPayActivityOrder(Integer uid, Integer activityId, String businessOrderNo);

    /**
     * 补请假回调
     */
    APIResponse supplementLeaveRefundOrderCallBack(RefundNotifyMsg refundNotifyMsg);

    APIResponse recoverySignUpNum(Integer limitNum,
                                  Integer activityId, Integer manCount,
                                  Integer femaleCount, int type);


    List<RespClubActivity> batchQueryActivityList(List<Integer> activityIdList);
}
